package com.ruoyi.logistic.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.logistic.domain.NetworkTransferMoney;
import com.ruoyi.logistic.domain.PageDate;
import com.ruoyi.logistic.domain.vo.NetworkTransferMoneyVo;
import com.ruoyi.logistic.mapper.NetworkTransferMoneyMapper;
import com.ruoyi.logistic.service.INetworkTransferMoneyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NetworkTransferMoneyServiceImpl implements INetworkTransferMoneyService {
    @Autowired
    private NetworkTransferMoneyMapper networkTransferMoneyMapper;

    @Override
    public List<NetworkTransferMoney> search(NetworkTransferMoneyVo networkTransferMoneyVo) {
        PageHelper.startPage(networkTransferMoneyVo.getPageDate());
        List<NetworkTransferMoney> networkTransferMoneyList = networkTransferMoneyMapper.search(networkTransferMoneyVo);
        assert networkTransferMoneyList != null;
        if (networkTransferMoneyList != null || networkTransferMoneyList.size() != 0){
            for (NetworkTransferMoney networkTransferMoney : networkTransferMoneyList){
                if (networkTransferMoneyVo.getCollectType() == 1){
                    networkTransferMoney.setCollectTime(networkTransferMoneyVo.getStartTime() + "至" + networkTransferMoneyVo.getEndTime());
                }else {
                    networkTransferMoney.setCollectTime(networkTransferMoneyVo.getMonth());
                }
            }
        }
        return networkTransferMoneyList;
    }
}
